using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.ItemMasters
{
    public partial class UnitGroupAutoMapperProfile : Profile
    {
        public UnitGroupAutoMapperProfile()
        {
            CreateMap<UnitGroup, UnitGroupDto>().MapExtraProperties().ReverseMap();
            CreateMap<UnitGroup, UnitGroupMainArchiveDto>().MapExtraProperties().ReverseMap();
            CreateMap<UnitGroup, UnitGroupCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<UnitGroup, UnitGroupUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<UnitGroupUpdateDto, UnitGroup>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.MainUnit, opt => opt.Ignore())
                .MapChildren<UnitGroupUpdateDto, UnitGroup, AuxiliaryUnitCreateOrUpdateDto, AuxiliaryUnit>();

            CreateMap<AuxiliaryUnit, AuxiliaryUnitDto>().MapExtraProperties().ReverseMap();
            CreateMap<AuxiliaryUnit, AuxiliaryUnitCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
}
